#!/bin/sh

#shell call java program

#pwd=`pwd`
#
#java -jar  ${pwd}/Test.jar
#
#exit 0;

#http://blog.chinaunix.net/uid-395020-id-2408842.html

# RND=_`date +%s%N`

#export JAVA_HOME=/home/buru/jdk/jdk1.8.0_102
#export M2_HOME=/home/buru/maven/apache-maven-3.3.1
#export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin:

#cd  /home/buru/gitosc/busuanzi
cd  /home/buru/awesome/busuanzi

NOW=`date '+%Y%m%d_%H%M%S'`
SERVICE=busuanzi-jar-with-dependencies

git pull

mvn clean package

kill -9 $(ps -ef|grep $SERVICE |gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ')

mkdir -p dist
mkdir -p dist/backups

mv dist/*.jar dist/backups
mv dist/*.log dist/backups

cp target/$SERVICE.jar  dist/$SERVICE-$NOW.jar

cd dist

nohup java -jar $SERVICE-$NOW.jar &> $SERVICE-$NOW.log&